<!-- This page asks students for their country of citizenship. They can
     choose from a list of countries, which is displayed in a 3-column
     format. 
     
     Upon clicking submit, they are led to the Country of
     Residence Page -->

<%@page import="support.*, java.util.*, java.sql.*, javax.sql.*" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> 
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<jsp:useBean id="aBean" scope="session" class="java.lang.String">
</jsp:useBean>
<html>
<head><title>Citizenship Page</title></head>
<body>

<CENTER>
<h1> Graduate School Application </h1>
<h2> Country of Citizenship Page </h2>
</CENTER>

<!-- Display data collected from previous pages. -->

<b>First Name:</b> <bean:write name="studentsinfoform" property="first" />
<span style="padding-left:20px"><b>Middle Initial:</b> <bean:write name="studentsinfoform" property="middle" /></span>
<span style="padding-left:20px"><b>Last Name:</b>  <bean:write name="studentsinfoform" property="last" /> </span>

<!-- End of displaying collected information. -->

<br><b>Please select your country of citizenship.</b> <p>
  
<% 
   	support s = new support();   	
   	
   	String path1 = config.getServletContext().getRealPath("countries.txt");

   	Vector countries = s.getCountries(path1);  
    String citizen = "", country1 = "", country2 = "", country3 = "";
   	
    int csize = countries.size()/3;
    int leftover = countries.size()%3;
    int spacing = 40;
    
    RowSet countriesDATA = (RowSet) request.getAttribute("crsCountries");
    
%>
	<TABLE BORDER CELLSPACING=1 CELLPADDING=5>
	<TR>
<%
    //print all the countries
    for(int i=0; i<countries.size()/3+1; i++)
    {
      // first column of countries
      if(i == leftover+csize)
      {
      	 break;
      }
      
      //country1 = countriesDATA.getString("country");
     countriesDATA.next();
%>
	  <TD>
	    <html:link action="/citizenship">
		<html:param name="citizen" value='<%= countriesDATA.getString("country") %>'/> <%= countriesDATA.getString("country") %>
		</html:link>
	  </TD>
<%   
      // second column of countries
      if( i+ leftover+csize == leftover+csize*2) 
      {
    	  break;
      }
	  countriesDATA.next();
	 // country2 = countries.get(i+leftover+csize).toString();
      
 %>
	  <TD>
	    <html:link action="/citizenship">
		<html:param name="citizen" value='<%= countriesDATA.getString("country") %>'/> <%= countriesDATA.getString("country") %>
		</html:link>
	  </TD>
<%      
      // third column of countries
      if(i+ leftover+csize*2 >= countries.size())
      {
    	  break;
      }
	  countriesDATA.next();
	 // countriesDATA.getString("country")countries.get(i+leftover+csize*2).toString();
      
%>
      <TD>
	    <html:link action="/citizenship">
		<html:param name="citizen" value='<%=  countriesDATA.getString("country")  %>'/> <%= countriesDATA.getString("country") %>
		</html:link>
      </TD>
	  </TR>
<%      
    } // end of print-countries-for-loop
    out.println("<br>");
%>

</TABLE>
</body>
</html>